home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / carlcalderon / arthropod / Debug.as
Text File  |  2008-11-04  |  6KB  |  189 lines

  1. package com.carlcalderon.arthropod
  2. {
  3.    import flash.display.BitmapData;
  4.    import flash.display.Stage;
  5.    import flash.events.StatusEvent;
  6.    import flash.geom.Matrix;
  7.    import flash.geom.Rectangle;
  8.    import flash.net.LocalConnection;
  9.    import flash.system.System;
  10.    
  11.    public class Debug
  12.    {
  13.       
  14.       public static var LIGHT_BLUE:uint = 52428;
  15.       
  16.       private static const MEMORY_OPERATION:String = "debugMemory";
  17.       
  18.       public static const NAME:String = "Debug";
  19.       
  20.       public static var secureDomain:String = "*";
  21.       
  22.       public static var password:String = "CDC309AF";
  23.       
  24.       private static const ERROR_OPERATION:String = "debugError";
  25.       
  26.       private static const CLEAR_OPERATION:String = "debugClear";
  27.       
  28.       private static const BITMAP_OPERATION:String = "debugBitmapData";
  29.       
  30.       public static const VERSION:String = "0.74";
  31.       
  32.       private static const TYPE:String = "app";
  33.       
  34.       public static var allowLog:Boolean = true;
  35.       
  36.       private static const ARRAY_OPERATION:String = "debugArray";
  37.       
  38.       private static const DOMAIN:String = "com.carlcalderon.Arthropod";
  39.       
  40.       private static const OBJECT_OPERATION:String = "debugObject";
  41.       
  42.       private static const WARNING_OPERATION:String = "debugWarning";
  43.       
  44.       public static var BLUE:uint = 6710988;
  45.       
  46.       private static const CONNECTION:String = "arthropod";
  47.       
  48.       public static var GREEN:uint = 52224;
  49.       
  50.       public static var ignoreStatus:Boolean = true;
  51.       
  52.       private static const CHECK:String = ".161E714B6C1A76DE7B9865F88B32FCCE8FABA7B5.1";
  53.       
  54.       public static var RED:uint = 13369344;
  55.       
  56.       private static const LOG_OPERATION:String = "debug";
  57.       
  58.       public static var secure:Boolean = false;
  59.       
  60.       public static var YELLOW:uint = 13421568;
  61.       
  62.       public static var PINK:uint = 13369548;
  63.       
  64.       private static var lc:LocalConnection = new LocalConnection();
  65.       
  66.       private static var hasEventListeners:Boolean = false;
  67.        
  68.       
  69.       public function Debug()
  70.       {
  71.          super();
  72.       }
  73.       
  74.       public static function memory() : Boolean
  75.       {
  76.          return send(MEMORY_OPERATION,System.totalMemory,null);
  77.       }
  78.       
  79.       public static function error(param1:*) : Boolean
  80.       {
  81.          return send(ERROR_OPERATION,String(param1),13369344);
  82.       }
  83.       
  84.       public static function warning(param1:*) : Boolean
  85.       {
  86.          return send(WARNING_OPERATION,String(param1),13421568);
  87.       }
  88.       
  89.       private static function send(param1:String, param2:*, param3:*) : Boolean
  90.       {
  91.          var operation:String = param1;
  92.          var value:* = param2;
  93.          var prop:* = param3;
  94.          if(!secure)
  95.          {
  96.             lc.allowInsecureDomain("*");
  97.          }
  98.          else
  99.          {
  100.             lc.allowDomain(secureDomain);
  101.          }
  102.          if(!hasEventListeners)
  103.          {
  104.             if(ignoreStatus)
  105.             {
  106.                lc.addEventListener(StatusEvent.STATUS,ignore);
  107.             }
  108.             else
  109.             {
  110.                lc.addEventListener(StatusEvent.STATUS,status);
  111.             }
  112.             hasEventListeners = true;
  113.          }
  114.          if(allowLog)
  115.          {
  116.             try
  117.             {
  118.                lc.send(TYPE + "#" + DOMAIN + CHECK + ":" + CONNECTION,operation,password,value,prop);
  119.                return true;
  120.             }
  121.             catch(e:*)
  122.             {
  123.                return false;
  124.             }
  125.          }
  126.          else
  127.          {
  128.             return false;
  129.          }
  130.       }
  131.       
  132.       public static function bitmap(param1:*, param2:String = null) : Boolean
  133.       {
  134.          var _loc3_:BitmapData = null;
  135.          var _loc4_:Matrix = null;
  136.          var _loc5_:Number = NaN;
  137.          var _loc6_:Rectangle = null;
  138.          _loc3_ = new BitmapData(100,100,true,16777215);
  139.          _loc4_ = new Matrix();
  140.          _loc5_ = 100 / (param1.width >= param1.height ? param1.width : param1.height);
  141.          _loc4_.scale(_loc5_,_loc5_);
  142.          _loc3_.draw(param1,_loc4_,null,null,null,true);
  143.          _loc6_ = new Rectangle(0,0,Math.floor(param1.width * _loc5_),Math.floor(param1.height * _loc5_));
  144.          return send(BITMAP_OPERATION,_loc3_.getPixels(_loc6_),{
  145.             "bounds":_loc6_,
  146.             "lbl":param2
  147.          });
  148.       }
  149.       
  150.       public static function object(param1:*) : Boolean
  151.       {
  152.          return send(OBJECT_OPERATION,param1,null);
  153.       }
  154.       
  155.       public static function clear() : Boolean
  156.       {
  157.          return send(CLEAR_OPERATION,0,0);
  158.       }
  159.       
  160.       private static function ignore(param1:StatusEvent) : void
  161.       {
  162.       }
  163.       
  164.       public static function log(param1:*, param2:uint = 16711422) : Boolean
  165.       {
  166.          return send(LOG_OPERATION,String(param1),param2);
  167.       }
  168.       
  169.       public static function array(param1:Array) : Boolean
  170.       {
  171.          return send(ARRAY_OPERATION,param1,null);
  172.       }
  173.       
  174.       public static function snapshot(param1:Stage, param2:String = null) : Boolean
  175.       {
  176.          if(param1)
  177.          {
  178.             return bitmap(param1,param2);
  179.          }
  180.          return false;
  181.       }
  182.       
  183.       private static function status(param1:StatusEvent) : void
  184.       {
  185.          trace("Arthropod status:\n" + param1.toString());
  186.       }
  187.    }
  188. }
  189.